﻿using SolutionUsingThreadsInModel.Common.Commands;
using SolutionUsingThreadsInModel.Model;

namespace SolutionUsingThreadsInModel.ViewModel
{
    public class TimeConsumingProcessViewModel : ViewModelBase
    {
        private readonly TimeConsumingProcessModel _model;

        public TimeConsumingProcessViewModel(TimeConsumingProcessModel model)
        {
            _model = model;
            _model.PropertyChanged += _model_PropertyChanged;
        }

        void _model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if(IsValidProperty(e.PropertyName))
                OnPropertyChanged(e.PropertyName);
        }

        private RelayCommand _incrementCounterCommand;
        public RelayCommand IncrementCounterCommand
        {
            get { return _incrementCounterCommand ?? (_incrementCounterCommand = new RelayCommand(param => _model.IncrementCounter())); }
        }

        public int Counter1
        {
            get { return _model.Counter1; }
            set { _model.Counter1 = value; }
        }


        private RelayCommand _decrementCounterCommand;
        public RelayCommand DecrementCounterCommand
        {
            get { return _decrementCounterCommand ?? (_decrementCounterCommand = new RelayCommand(param => _model.DecrementCounter())); }
        }

        public int Counter2
        {
            get { return _model.Counter2; }
            set { _model.Counter2 = value; }
        }

    }
}
